<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>注册</title>
</head>
<body>

<div class="form-div">
    <div class="reg-content">
        <h1>欢迎注册</h1>
        <span>已有帐号？</span> <a href="login.html">登录</a>
    </div>
    <form id="reg-form" action="/register" method="POST">

        <table>

            <tr>
                <td>账号</td>
                <td class="inputs">
                    <input name="account" type="text" id="account">
                    <br>
                    <span id="account_err" class="err_msg" style="display: none">用户名已经存在</span>
                </td>

            </tr>

            <tr>
                <td>密码</td>
                <td class="inputs">
                    <input name="password" type="password" id="password">
                    <br>
                    <span id="password_err" class="err_msg" style="display: none">密码格式有误</span>
                </td>
            </tr>


        </table>

        <div class="buttons">
            <input value="注 册" type="submit" id="reg_btn">
        </div>
        <br class="clear">
    </form>

</div>
</body>
<script>
    //失去焦点
    document.getElementById("account").onblur = function () {
        axios.request({
            methods: 'get',
            url: '/register',
            params: {
                account: this.value
            }
        }).then(function (response) {
            console.log(response);
            if ("no" === response.data) {
                document.getElementById("account_err").style.display = 'none';
            } else {
                document.getElementById("account_err").style.display = '';
            }
        })

    }


</script>
<style>
    * {
        margin: 0;
        padding: 0;
        list-style-type: none;
    }

    .reg-content {
        padding: 30px;
        margin: 3px;
    }

    a, img {
        border: 0;
    }

    body {
        background-image: url();
        text-align: center;
    }

    table {
        border-collapse: collapse;
        border-spacing: 0;
    }

    td, th {
        padding: 0;
        height: 90px;

    }

    .inputs {
        vertical-align: top;
    }

    .clear {
        clear: both;
    }

    .clear:before, .clear:after {
        content: "";
        display: table;
    }

    .clear:after {
        clear: both;
    }

    .form-div {
        background-color: rgba(255, 255, 255, 0.27);
        border-radius: 10px;
        border: 1px solid #aaa;
        width: 424px;
        margin-top: 150px;
        margin-left: 500px;
        padding: 30px 0 20px 0px;
        font-size: 16px;
        box-shadow: inset 0px 0px 10px rgba(255, 255, 255, 0.5), 0px 0px 15px rgba(75, 75, 75, 0.3);
        text-align: left;
    }

    .form-div input[type="text"], .form-div input[type="password"], .form-div input[type="email"] {
        width: 268px;
        margin: 10px;
        line-height: 20px;
        font-size: 16px;
    }

    .form-div input[type="checkbox"] {
        margin: 20px 0 20px 10px;
    }

    .form-div input[type="button"], .form-div input[type="submit"] {
        margin: 10px 20px 0 0;
    }

    .form-div table {
        margin: 0 auto;
        text-align: right;
        color: rgba(64, 64, 64, 1.00);
    }

    .form-div table img {
        vertical-align: middle;
        margin: 0 0 5px 0;
    }


    .form-div .buttons {
        float: right;
    }

    input[type="text"], input[type="password"], input[type="email"] {
        border-radius: 8px;
        box-shadow: inset 0 2px 5px #eee;
        padding: 10px;
        border: 1px solid #D4D4D4;
        color: #333333;
        margin-top: 5px;
    }

    input[type="text"]:focus, input[type="password"]:focus, input[type="email"]:focus {
        border: 1px solid #50afeb;
        outline: none;
    }

    input[type="button"], input[type="submit"] {
        padding: 7px 15px;
        background-color: #3c6db0;
        text-align: center;
        border-radius: 5px;
        overflow: hidden;
        min-width: 80px;
        border: none;
        color: #FFF;
        box-shadow: 1px 1px 1px rgba(75, 75, 75, 0.3);
    }

    input[type="button"]:hover, input[type="submit"]:hover {
        background-color: #5a88c8;
    }

    input[type="button"]:active, input[type="submit"]:active {
        background-color: #5a88c8;
    }

    .err_msg {
        color: red;
        padding-right: 170px;
    }

    #password_err, #tel_err {
        padding-right: 195px;
    }

    #reg_btn {
        margin-right: 50px;
        width: 285px;
        height: 45px;
        margin-top: 20px;
    }
</style>
</html>